/*
 * Bomb.cpp
 *
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses 
 */

#include "Bomb.h"
#include "Properties.h"
#include "ExplosionEffect.h"

Bomb::Bomb() {
    init();
    owner = 0;
}

Bomb::Bomb(int x, int y)
    : Positionable(x, y) {
    init();
    owner = 0;
}

Bomb::Bomb(int id, int x, int y)
    : Positionable(x, y), Identifiable(id) {
    init();
    owner = 0;
}

Bomb::Bomb(int x, int y, MapObject* owner)
    : Positionable(x, y), owner(owner) {
    init();
}

Bomb::Bomb(int id, int x, int y, MapObject* owner)
    : Positionable(x, y), Identifiable(id), owner(owner) {
    init();
}

void Bomb::init() {
    Properties properties = Properties();
    damage = properties.getPropertyAsInt("bomb_damage");
    range = properties.getPropertyAsInt("bomb_range");
    triggered = false;
}

int Bomb::getDamage() {
    return damage;
}

int Bomb::getRange() {
    return range;
}

bool Bomb::isTriggered() {
    return triggered;
}

void Bomb::trigger() {
    triggered = true;
}

MapObject* Bomb::getOwner() {
    return owner;
}

void Bomb::setOwner(MapObject* owner) {
    this->owner = owner;
}

void Bomb::explode() {
    notify(BOMB_EXPLODED, this);
}

MapEffect* Bomb::getExplosionEffect() {
    return new ExplosionEffect(this);
}

Bomb* Bomb::clone() {
    return new Bomb(*this);
}

Bomb::~Bomb() {

}
